/**
 * Copyright (c) 2024 - CARThunder
 * All Rights Reserved by Chengdu CARThunder Intelligent Technology Co., LTD and its affiliates.
 * You may not use, copy, distribute, modify, transmit in any form this file
 * except in compliance with CARThunder in writing by applicable law.
 *
 */

/**
 * file description.
 * @file    filename
 * @brief   brief function description.
 * @details detailed function description.
 * @version 1.0
 * @author  author_name
 * @date    last_modified_date
 *
 *      Edit History
 *      ----------------------------------------------------------------------------
 *      DATE                     NAME               DESCRIPTION
 *      2024-07-30              junjieluo         Create it.
 *
 */


package com.cart.musicdemo.view;

import android.content.Context;
import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.cart.musicdemo.R;


/**
 * The type No data view.
 */
public class NoDataView extends RelativeLayout {

    private final RelativeLayout mRlNoDataRoot;
    private final ImageView mImgNoDataView;

    /**
     * Instantiates a new No data view.
     *
     * @param context the context
     * @param attrs   the attrs
     */
    public NoDataView(Context context, AttributeSet attrs) {
        super(context, attrs);
        inflate(context, R.layout.view_no_data, this);
        mRlNoDataRoot = findViewById(R.id.rl_no_data_root);
        mImgNoDataView = findViewById(R.id.img_no_data);
    }

    /**
     * Sets no data background.
     *
     * @param colorResId the color res id
     */
    public void setNoDataBackground(@ColorRes int colorResId) {
        mRlNoDataRoot.setBackgroundColor(getResources().getColor(colorResId));
    }

    /**
     * Sets no data view.
     *
     * @param imgResId the img res id
     */
    public void setNoDataView(@DrawableRes int imgResId) {
        mImgNoDataView.setImageResource(imgResId);
    }
}